package com.hq.ims.data.service;

import com.hq.ims.data.dao.CompanyCheckMapper;
import com.hq.ims.data.entity.CompanyCheck;
import com.hq.ims.data.entityenum.EnumAuditStatus;
import com.hq.ims.data.utils.LocalConstant;
import com.hq.ims.data.vo.CompanyCheckMapstruct;
import com.hq.mybatis.base.BaseService;
import org.springframework.stereotype.Service;


/**
 * @Author jiang bai ping
 * @Email 526666031@qq.com
 * @DateTime 2024-10-28 09:05:29
 * @Detail 企业信息服务实现类
 */
@Service
public class BaseCompanyCheckService extends BaseService<CompanyCheckMapper, CompanyCheck> {


    /**
     * 获取最新一条审核
     * @param companyId
     * @return
     */
    public CompanyCheck getLastCheckByCompanyId(String companyId) {
        return this.lambdaQuery().eq(CompanyCheck::getCompanyId, companyId).orderByDesc(CompanyCheck::getCreateDateTime).last(LocalConstant.LIMIT_1).one();
    }

    /**
     * 是否初次审核
     * @param companyId
     * @return
     */
    public boolean isFirstCheck(String companyId) {
        return this.lambdaQuery().eq(CompanyCheck::getCompanyId, companyId).eq(CompanyCheck::getAuditStatus, EnumAuditStatus.Pass).count() == 0;
    }
}
